package com.fanqwz.kotlinmvvm.di.module

import android.arch.persistence.room.Room
import android.content.Context
import com.fanqwz.kotlinmvvm.MyApplication
import com.fanqwz.kotlinmvvm.data.persist.db.UserDatabase
import com.fanqwz.kotlinmvvm.data.repository.UserDataRepository
import com.fanqwz.kotlinmvvm.domain.repo.UserRepository
import dagger.Binds
import dagger.Module
import dagger.Provides
import javax.inject.Singleton

/**
 * Created by fanqwz on 2018/3/5.
 */


@Module
abstract class RepositoryModule {
    @Binds
    @Singleton
    abstract fun provideRepo(userDataRepository: UserDataRepository): UserRepository

    @Module
    companion object {
        @Provides
        @Singleton
        @JvmStatic
        fun provideUserDataBase(context: Context): UserDatabase {
            return Room.databaseBuilder(context.applicationContext, UserDatabase::class.java, "users.db").build()
        }
    }
}
